#coding=utf-8
#Boa:Dialog:DlgLendEditor

import wx

def create(parent):
    return DlgLendEditor(parent)

[wxID_DLGLENDEDITOR, wxID_DLGLENDEDITORBTNCANCEL, wxID_DLGLENDEDITORBTNOK, 
 wxID_DLGLENDEDITORCBSTAFF, wxID_DLGLENDEDITORCHECKLEND, 
 wxID_DLGLENDEDITORCHECKMONEY, wxID_DLGLENDEDITORDATEBILL, 
 wxID_DLGLENDEDITORSTATICTEXT1, wxID_DLGLENDEDITORTCMONEY, 
 wxID_DLGLENDEDITORTCNUM, wxID_DLGLENDEDITORTCPRICE, wxID_DLGLENDEDITORTCPRO, 
 wxID_DLGLENDEDITORTCUNIT, wxID_DLGLENDEDITORTHANDLER, 
] = [wx.NewId() for _init_ctrls in range(14)]

[Type_Lendin, Type_Lendout] = [1,2]
 
class DlgLendEditor(wx.Dialog):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Dialog.__init__(self, id=wxID_DLGLENDEDITOR, name=u'DlgLendEditor',
              parent=prnt, pos=wx.Point(542, 252), size=wx.Size(543, 386),
              style=wx.DEFAULT_DIALOG_STYLE, title=u'\u65b0\u589e\u9879')
        self.SetClientSize(wx.Size(535, 352))
        self.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, False,
              u'\u6977\u4f53_GB2312'))
        self.Center(wx.BOTH)

        self.checkMoney = wx.CheckBox(id=wxID_DLGLENDEDITORCHECKMONEY,
              label=u'\u65b0\u589e\u4ed8\u6b3e', name=u'checkMoney',
              parent=self, pos=wx.Point(56, 40), size=wx.Size(88, 14), style=0)
        self.checkMoney.SetValue(True)
        self.checkMoney.Bind(wx.EVT_CHECKBOX, self.OnCheckMoneyCheckbox,
              id=wxID_DLGLENDEDITORCHECKMONEY)

        self.tcMoney = wx.TextCtrl(id=wxID_DLGLENDEDITORTCMONEY,
              name=u'tcMoney', parent=self, pos=wx.Point(152, 32),
              size=wx.Size(100, 26), style=0, value=u'')

        self.checkLend = wx.CheckBox(id=wxID_DLGLENDEDITORCHECKLEND,
              label=u'\u65b0\u589e\u501f\u5165', name=u'checkLend', parent=self,
              pos=wx.Point(56, 104), size=wx.Size(105, 16), style=0)
        self.checkLend.SetValue(True)
        self.checkLend.Bind(wx.EVT_CHECKBOX, self.OnCheckLendCheckbox,
              id=wxID_DLGLENDEDITORCHECKLEND)

        self.staticText1 = wx.StaticText(id=wxID_DLGLENDEDITORSTATICTEXT1,
              label=u'\u4ea7\u54c1             \u5355\u4f4d  \u6570\u91cf     \u5355\u4ef7',
              name='staticText1', parent=self, pos=wx.Point(80, 136),
              size=wx.Size(316, 16), style=0)

        self.tcPro = wx.TextCtrl(id=wxID_DLGLENDEDITORTCPRO, name=u'tcPro',
              parent=self, pos=wx.Point(80, 160), size=wx.Size(152, 26),
              style=0, value=u'')

        self.tcUnit = wx.TextCtrl(id=wxID_DLGLENDEDITORTCUNIT, name=u'tcUnit',
              parent=self, pos=wx.Point(232, 160), size=wx.Size(32, 26),
              style=0, value=u'')

        self.tcNum = wx.TextCtrl(id=wxID_DLGLENDEDITORTCNUM, name=u'tcNum',
              parent=self, pos=wx.Point(264, 160), size=wx.Size(72, 26),
              style=0, value=u'')

        self.tcPrice = wx.TextCtrl(id=wxID_DLGLENDEDITORTCPRICE,
              name=u'tcPrice', parent=self, pos=wx.Point(336, 160),
              size=wx.Size(80, 26), style=0, value=u'')

        self.dateBill = wx.DatePickerCtrl(id=wxID_DLGLENDEDITORDATEBILL,
              name=u'dateBill', parent=self, pos=wx.Point(312, 32),
              size=wx.Size(130, 24), style=wx.DP_DROPDOWN | wx.DP_SHOWCENTURY)

        self.btnOK = wx.Button(id=wxID_DLGLENDEDITORBTNOK,
              label=u'\u786e\u8ba4', name=u'btnOK', parent=self,
              pos=wx.Point(144, 288), size=wx.Size(93, 26), style=0)
        self.btnOK.Bind(wx.EVT_BUTTON, self.OnBtnOKButton,
              id=wxID_DLGLENDEDITORBTNOK)

        self.btnCancel = wx.Button(id=wxID_DLGLENDEDITORBTNCANCEL,
              label=u'\u53d6\u6d88', name=u'btnCancel', parent=self,
              pos=wx.Point(328, 288), size=wx.Size(93, 26), style=0)
        self.btnCancel.Bind(wx.EVT_BUTTON, self.OnBtnCancelButton,
              id=wxID_DLGLENDEDITORBTNCANCEL)

        self.tHandler = wx.StaticText(id=wxID_DLGLENDEDITORTHANDLER,
              label=u'\u7ecf\u529e\u4eba\uff1a', name=u'tHandler', parent=self,
              pos=wx.Point(56, 232), size=wx.Size(68, 16), style=0)

        self.cbStaff = wx.ComboBox(choices=[], id=wxID_DLGLENDEDITORCBSTAFF,
              name=u'cbStaff', parent=self, pos=wx.Point(136, 224),
              size=wx.Size(150, 24), style=0, value=u'')
        self.cbStaff.SetLabel(u'')

    def __init__(self, parent, type):
        self._init_ctrls(parent)
        
        self.myInit(type)
        
    def myInit(self, type):
        self.curType = type
        
        if (type == Type_Lendin):
            pass
        elif (type == Type_Lendout):
            self.checkLend.SetLabel(u'新增借出')

        self.dateBill.SetValue(wx.DateTime.Today())
        
        self.enableMoney(self.checkMoney.GetValue())
        self.enableLend(self.checkLend.GetValue())

    def enableMoney(self, enable):
        self.tcMoney.Enable(enable)
        if not enable:
            self.tcMoney.SetValue('')
        
    def enableLend(self, enable):
        self.tcPro.Enable(enable)
        self.tcUnit.Enable(enable)
        self.tcNum.Enable(enable)
        self.tcPrice.Enable(enable)
        
        if not enable:
            self.tcPro.SetValue('')
            self.tcUnit.SetValue('')
            self.tcNum.SetValue('')
            self.tcPrice.SetValue('')
            
         
    def OnCheckMoneyCheckbox(self, event):
        self.enableMoney(self.checkMoney.GetValue())

    def OnCheckLendCheckbox(self, event):
        self.enableLend(self.checkLend.GetValue())

    def OnBtnOKButton(self, event):
        event.Skip()

    def OnBtnCancelButton(self, event):
        event.Skip()
